package yf.mall.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yf.mall.dao.MallActDao;
import yf.mall.entity.MallActEntity;
import yf.mall.service.SumService;

import java.util.List;

/**
 * @author xiaolongtongxie
 * @version 1.0
 * @date 2020/5/25 15:09
 */
@Service
@Slf4j
public class SumServiceImpl implements SumService {
    @Autowired
    private MallActDao mallActDao;
    @Override
    public Integer sumUserBuyNumber(Long actId, Long userId) {
        MallActEntity actEntity = mallActDao.get(actId);
        return mallActDao.sumUserBuyNumber(actEntity.getStart(), actEntity.getEnd(), actEntity.getGoodsId(), userId);
    }

    @Override
    public List<Object[]> sumTopUserBuy(Long actId,Integer limit) {
        MallActEntity actEntity = mallActDao.get(actId);
        return mallActDao.sumTopUserBuy(actEntity.getStart(),actEntity.getEnd(),actEntity.getGoodsId(),limit);
    }


}
